package com.qidian.client;

public class Transer extends BaseTranser{
	 static
	 {
		 //System.loadLibrary("Transer"); //
		 System.load("C:/dlls/Transer.dll");
	 }
	 
	 public native int getValue();
	 public native void setValue(int i);

	 public native String SendImage(String validatestr, long gameid, long X, long y, long w, long h, long cstime);
			
	 public native String SendFile(String validatestr, long gameid, String picpath, long cstime) ;
			
	 public native String SendGif(String validatestr, long gameid, String picpath, long cstime) ;
		
	 public native String GetAnswer(String id) ;
			
	 public native String Report(String id, String validatestr) ;
			
	 public static Transer instance = new Transer() ;
	 
	 public Transer()
	 {
	 }
	 
//	 public static Transer getInstance(){
//		 return instance ;
//	 }
	 
	 /**
	  * @param args
	  */
	 public static void main(String[] args) 
	 {
		 Transer test=new Transer();
		 test.setValue(10);
		 System.out.println(test.SendFile(null, 0, null, 0)) ;
		 System.out.println(test.getValue());  
	 }
	 
	 
	 public boolean isWrong(String answer)
	 {
		 // 空值或者'-'开头的除'-2'以外的字符串
		 return answer == null || 
		 	(answer.length()>=2 && answer.charAt(0) == '-' && answer.charAt(1) != '2') ;
	 }
	 public boolean isNotReady(String answer)
	 {
		 return answer != null && answer.equals("-2") ;
	 }
	 public String mapGameType(int gameType)
	 {
		 return String.valueOf(gameType) ;
	 }
	@Override
	public String getAnswer(String msgId, String[] otherArgs) 
	{
		String answer = GetAnswer(msgId) ;
		System.out.println("Get answer : '"+answer+"' for " + msgId ) ;
		return answer;
	}
	@Override
	public String report(String account, String msgId, String[] otherArgs) 
	{
		String result =  Report(account,msgId);
		System.out.println("Report : " + result + " for "+ msgId) ;
		return result ;
	}
	@Override
	public String sendFile(String account, String filePath, String interval,
			String gameType, String[] otherArgs) 
	{
		String msgId =  SendFile(account,Long.parseLong(gameType),filePath,Long.parseLong(interval)) ;
		System.out.println("Send file : " + msgId + " for account:"+ account) ;
		return msgId ;
	}
	@Override
	public boolean isAnswer(String answer) 
	{
		return answer != null && (answer.length() == 0 || answer.charAt(0) != '-');
	}
	@Override
	public boolean isSendOK(String returnCode) 
	{
		return returnCode != null && returnCode.length() > 0 && returnCode.charAt(0) != '-';
	}
	 
}